#include <iostream>
#include <algorithm>

using namespace std;

void mutable_lambda()
{
    int local_val = 5;
    auto f = [local_val]() mutable -> bool
    {
        if (local_val > 0)
        {
            local_val--;
            return false;
        }
        return true;
    };
    for (int i = 0; i < 10; ++i)
    {
        cout << f() << endl;
    }
    cout << local_val << endl; // keep ori-value using `value + mutable`
                               // change value using ref `&value`
}

int main()

{
    mutable_lambda();
    return 0;
}